<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends MY_Luckydog
{
	public function __construct()
	{
		parent::__construct();
        $this->load->model('luckydog/User_model', 'user');
        $login_status = $this->login_status = $this->check_login_status();
        if (empty($login_status)){
            redirect('/luckydog/login');
        }
	}



  
 public function index()
    {
        $_SESSION['v_menu'] = 'user';
        $starttime = $this->input->get("starttime",true)?$this->input->get("starttime",true):"";
        $endtime = $this->input->get("endtime",true)?$this->input->get("endtime",true):"";
        $per_page = $this->input->get('per_page') ? $this->input->get('per_page') : 0;
        $contact = $this->input->get('contact') ? $this->input->get('contact') : "";
        $name = $this->input->get('name') ? $this->input->get('name') : "";
        $sign = $this->input->get('sign') ? $this->input->get('sign') : "";
        $filter = array(
            'starttime'=>strtotime($starttime),
            'endtime'=>strtotime($endtime),
            'contact'=>($contact),
            'name'=>$name,
            'sign'=>$sign
        );
        $limit = 20;
        $total_rows = $this->user->get_user_cnt($filter);
        $base_url = '/luckydog/user/index?';
        $page_links = $this->create_page_links($base_url,$total_rows,$limit);
        $userList = $this->user->userList($filter,$per_page,$limit);

        
        $data = array(
            'userList'=>$userList,
            'page_links'=>$page_links,
            'per_page'=>$per_page,
            'total_rows'=>$total_rows,
        );
        $this->load->view('/luckydog/user/user_list',$data);
    }

    /**
     *------------------------------------------------------------------------------------------------------------------
     * @title：编辑用户停用启用
     * @param：id      
     * @author:：柏凯
     * @date：2015-09-22
     *------------------------------------------------------------------------------------------------------------------
     */
    public function editStatus(){
        $id = $this->input->post("id",true) ? $this->input->post("id",true) : 0;
        $status = $this->input->post("status",true) ? $this->input->post("status",true) : "";
        $data = array(
            "id"=>$id,
            "Status"=>$status
        );
        $res =$this->user->editStatus("bp_user",$data);
        echo $res;
    }


}
/* End of file user.php */
/* Location: ./application/controllers/luckydog/user.php */